﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Liolikas.Scores
{
    class Score
    {
        public int points;
        public String data;
        static char SAVED_DATA_FIELDS_DELIMETER = '#';

        public Score(int score, string data)
        {
            this.points = score;
            this.data = data;
        }

        internal void saveData(StreamWriter writer)
        {
            writer.WriteLine(points + SAVED_DATA_FIELDS_DELIMETER.ToString() + data);
        }

        internal static Score LoadScore(string line)
        {
            try
            {
                string[] data = line.Split(SAVED_DATA_FIELDS_DELIMETER);
                return new Score(int.Parse(data[0]), data[1]);
                
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                return null;
            }
            
        }
    }
}
